﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using Gift.DAL;
using Gift.Model;

namespace WebSite.cn
{
    public partial class NewBulletin : System.Web.UI.UserControl
    {

        string _bulletinMsg;

        public string newsmsg = "";

        public string BulletinMsg
        {
            get { return _bulletinMsg; }
            set { _bulletinMsg = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dtBulletin = SQLAccess.GreatDs("select top 1 newsid,newsname,newscontent,typeid from DB_News where typeid in(3) and visible=1 and isnew=1 order by newsorder,updatetime desc").Tables[0];
                if (dtBulletin.Rows.Count > 0)
                {
                    _bulletinMsg = dtBulletin.Rows[0]["newscontent"].ToString();
                    if (_bulletinMsg.Length > 140)
                    {
                        _bulletinMsg = _bulletinMsg.Substring(0, 100);
                    }
                    _bulletinMsg = _bulletinMsg + "...<a href='news_01.aspx?tid=" + dtBulletin.Rows[0]["typeid"].ToString() + "&nid=" + dtBulletin.Rows[0]["newsid"].ToString() + "' title='" + dtBulletin.Rows[0]["newsname"].ToString() + "'>详细</a>";
                }

                DataTable table = SQLAccess.GreatDs(string.Concat(new object[] { "select top ", Convert.ToInt32(info.info1("", "homeshownnum")), " newsid,newsname,typeid from DB_News where typeid in(", re.returnnewstype("2", "1"), ") and visible=1 and isnew=1 order by newsorder,updatetime desc" })).Tables[0];
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        string newsmsg = this.newsmsg;
                        this.newsmsg = newsmsg + "<li><a href='news_01.aspx?tid=" + row["typeid"].ToString() + "&nid=" + row["newsid"].ToString() + "' title='" + row["newsname"].ToString() + "'>" + row["newsname"].ToString() + "</a></li>";
                    }
                }
            }
        }
    }
}